package cn.tedu.controller;

import cn.tedu.dao.StudentMapper;
import cn.tedu.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.util.Arrays;

@RestController
@RequestMapping("stu")
public class StudentController {
    @Autowired(required = false)
    private StudentMapper studentMapper;
//    @RequestMapping("run")
//    public Integer run(Student stu){
//        return studentMapper.insertAll(stu);
//    }

    @RequestMapping("sel")
    public String checkNameThenInsert(Student stu){
        Student student = studentMapper.selectByName(stu.getName());
        if(student == null){
            studentMapper.insertAll(stu);
            return "成功";
        }else {
            return "失败";
        }



    }
}
